home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet internetowy / Menedzery hasel / Mateyko 2.0 / NetIDSetup.msi / _577F92E7A8A22FA500E912D074B5C998 / _6E0A66E3CB02449CBB252E3C2447B3CA / install.js next >
Text File  |  2006-04-04  |  5KB  |  148 lines

  1. // XpiInstaller
  2. // By Pike (Heavily inspired by code from Henrik Gemal and Stephen Clavering)
  3.  
  4. var XpiInstaller = {
  5.  
  6.     // --- Editable items begin ---
  7.     extFullName: 'Mateyko plugin', // The name displayed to the user (don't include the version)
  8.     extShortName: 'netidtoolbar', // The leafname of the JAR file (without the .jar part)
  9.     extVersion: '1.1',
  10.     extAuthor: 'focuscoding.com',
  11.     extLocaleNames: null, // e.g. ['en-US', 'en-GB']
  12.     extSkinNames: ['classic'], // e.g. ['classic', 'modern']
  13.     extPostInstallMessage: 'Success! Please restart your browser to finish the installation.', // Set to null for no post-install message
  14.     // --- Editable items end ---
  15.  
  16.     profileInstall: true,
  17.     silentInstall: false,
  18.  
  19.     install: function()
  20.     {
  21.         var jarName = this.extShortName + '.jar';
  22.         var profileDir = Install.getFolder('Profile', 'chrome');
  23.         
  24.         var errResult = 0;
  25.  
  26.         // Parse HTTP arguments
  27.         this.parseArguments();
  28.         
  29.         // Check if extension is already installed in profile
  30.         if (File.exists(Install.getFolder(profileDir, jarName)))
  31.         {
  32.             if (!this.silentInstall)
  33.             {
  34.                 Install.alert('Updating existing Profile install of ' + this.extFullName + ' to version ' + this.extVersion + '.');
  35.             }
  36.             this.profileInstall = true;
  37.         }
  38.         else if (!this.silentInstall)
  39.         {
  40.             // Ask user for install location, profile or browser dir?
  41.             this.profileInstall = Install.confirm('Install ' + this.extFullName + ' ' + this.extVersion + ' to your Profile directory (OK) or your Browser directory (Cancel)?');
  42.         }
  43.  
  44.         // Init install
  45.         var dispName = this.extFullName + ' ' + this.extVersion;
  46.         var regName = '/' + this.extAuthor + '/' + this.extShortName;
  47.         errResult = Install.initInstall(dispName, regName, this.extVersion);
  48.         logComment("initInstall() result: " + errResult);
  49.  
  50.         // Find directory to install into
  51.         var installPath;
  52.         if (this.profileInstall) 
  53.             installPath = profileDir;
  54.         else 
  55.             installPath = Install.getFolder('chrome');
  56.  
  57.         // Add JAR file
  58.         errResult = Install.addFile(null, 'chrome/' + jarName, installPath, null);
  59.         logComment("addFile( jar ) result: " + errResult);
  60.  
  61.         //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  62.         // Add dll & xpt files
  63.         
  64.         //var profileDirCOM = Install.getFolder('Profile', 'components');
  65.         //var installPathCOM;
  66.         //if (this.profileInstall) installPathCOM = profileDirCOM;
  67.         //else installPathCOM = Install.getFolder('components');
  68.  
  69.         
  70.         //alert( "Execute: " + execute( 'L_Caller.exe' ) );
  71.  
  72.         var installPathCOM = Install.getFolder('components');
  73.  
  74.         errResult = Install.addFile(null, 'components/NetIDCom.dll',  installPathCOM, null);
  75.         logComment("addFile( dll ) result: " + errResult);
  76.         errResult = Install.addFile(null, 'components/INetIDCom.xpt', installPathCOM, null);
  77.         logComment("addFile( xpt ) result: " + errResult);
  78.         //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  79.  
  80.         // Register chrome
  81.         var jarPath = Install.getFolder(installPath, jarName);
  82.         var installType = this.profileInstall ? Install.PROFILE_CHROME : Install.DELAYED_CHROME;
  83.  
  84.         // Register content
  85.         errResult = Install.registerChrome(Install.CONTENT | installType, jarPath, 'content/' + this.extShortName + '/');
  86.         logComment("registerChrome( content ) result: " + errResult);
  87.  
  88.         // Register locales
  89.         for (var locale in this.extLocaleNames)
  90.         {
  91.             var regPath = 'locale/' + this.extLocaleNames[locale] + '/' + this.extShortName + '/';
  92.             errResult = Install.registerChrome(Install.LOCALE | installType, jarPath, regPath);
  93.             logComment("registerChrome( locale ) result: " + errResult);
  94.         }
  95.  
  96.         // Register skins
  97.         for (var skin in this.extSkinNames)
  98.         {
  99.             var regPath = 'skin/' + this.extSkinNames[skin] + '/' + this.extShortName + '/';
  100.             errResult = Install.registerChrome(Install.SKIN | installType, jarPath, regPath);
  101.             logComment("registerChrome( skin ) result: " + errResult);
  102.         }
  103.  
  104.         // Perform install
  105.         var err = Install.performInstall();
  106.         logComment("performInstall() result: " + err);
  107.         if (err == Install.SUCCESS || err == Install.REBOOT_NEEDED)
  108.         {
  109.             if (!this.silentInstall && this.extPostInstallMessage)
  110.             {
  111.                 Install.alert(this.extPostInstallMessage);
  112.             }
  113.         }
  114.         else
  115.         {
  116.             this.handleError(err);
  117.             return;
  118.         }
  119.     },
  120.  
  121.     parseArguments: function()
  122.     {
  123.         // Can't use string handling in install, so use if statement instead
  124.         var args = Install.arguments;
  125.         if (args == 'p=0')
  126.         {
  127.             this.profileInstall = false;
  128.             this.silentInstall = true;
  129.         }
  130.         else if (args == 'p=1')
  131.         {
  132.             this.profileInstall = true;
  133.             this.silentInstall = true;
  134.         }
  135.     },
  136.  
  137.     handleError: function(err)
  138.     {
  139.         if (!this.silentInstall)
  140.         {
  141.             Install.alert('Error: Could not install ' + this.extFullName + ' ' + this.extVersion + ' (Error code: ' + err + ')');
  142.         }
  143.         Install.cancelInstall(err);
  144.     }
  145. };
  146.  
  147. XpiInstaller.install();
  148.